package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.CustomerPayment;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.PaymentContract;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CustomerPaymentDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "收款名称")
    private String paymentName;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "收款日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date repaymentTime;

    @ApiModelProperty(value = "收款方式：1银行卡2微信3支付宝")
    private Integer repaymentType;

    @ApiModelProperty(value = "收款总金额")
    private Double money;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "收款类型 1：合同 2：其他 3客户 ")
    private Integer paymentType;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "用户名称（添加人名称）")
    private String adminName;

    @ApiModelProperty(value = "收款账号")
    private String account;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFileList;

    @ApiModelProperty(value = "收款状态：0未收款 1已收款" )
    private Integer paymentStatus;

    @ApiModelProperty(value = "收款子表")
    private List<PaymentContract> paymentContracts;

//    @ApiModelProperty(value = "账单id")
//    private Integer billId;
//
//    @ApiModelProperty(value = "平账状态：0否 1是")
//    private Integer balancingAccounts;



    public CustomerPaymentDTO() {}

    public CustomerPaymentDTO(CustomerPayment entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static CustomerPaymentDTO convert(CustomerPayment entity) {
        return new CustomerPaymentDTO(entity);
    }

    public static List<CustomerPaymentDTO> convertList(List<CustomerPayment> list) {
        List<CustomerPaymentDTO> resultList = new ArrayList<>();
        for (CustomerPayment entity : list) {
            resultList.add(new CustomerPaymentDTO(entity));
        }
        return resultList;
    }}
